import Base from "../Base.js";
import cinemaApi from "../../api/cinemas.js"
// import { assignWith } from "lodash";
export default class Login extends Base {
constructor(props){
  super(props);
this.data={
_id:"",name:"",address:"",phone:"",status:"",

}


}
  render() {
    // 拿到数据库数据进行遍历
    this.el.html(`
    <form class="layui-form" style="background-color:white;padding-top:20px;padding-bottom:60px;padding-left:40px;padding-right:140px;width:500px">
    <h1 style="font-weight: 500;font-size:30px;text-align:center">新增影院</h1>
    <div class="layui-form-item">
      <label class="layui-form-label">影院名称</label>
      <div class="layui-input-block">
        <input type="text" name="cinemaName" lay-verify="title" autocomplete="off" placeholder="请输入院线影院名称" class="layui-input">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">请输入影院详细地址</label>
      <div class="layui-input-block">
        <input type="text" name="address"  lay-verify="title" autocomplete="off" placeholder="（XX区XX路XXX号）" class="layui-input">
      </div>
    </div> 
    <div class="layui-form-item">
      <label class="layui-form-label">联系电话</label>
      <div class="layui-input-block">
        <input type="text" name="phone" lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
      </div>
    </div>
    <div class="layui-form-item">
            <label class="layui-form-label">是否营业：</label>
            <div class="layui-input-block">
              <input type="radio" name="check" value="true" title="立即营业" checked>
              <input type="radio" name="check" value="false" title="暂不营业">
            </div>
          </div>
    </div>
    <div class="layui-form-item">
      <div class="layui-input-block">
      <input type="button" id="addBtn" class="layui-input" value="立即提交">
        
      </div>
    </div>
  </form>`);
 layui.form.render();

  }
  rerender() {


  }
  handle() {
  
$(`#addBtn`).on("click", async e=>{
 var name= $(`input[name=cinemaName]`).val();
  var address= $(`input[name=address]`).val();
  var phone= $(`input[name=phone]`).val();
  var status= $(`input[name=check]`).val();
  var data={
    name,address,phone,status
  };
  await cinemaApi.add(data);
  console.log(data);
   return false;

})


  }

}